package com.mccrea.principle.likso;

/**
 * @Classname LiksoAppMain
 * @Description 子类重写了父类的方法，破坏里式替换原则
 * @Date 2021/5/6 0006 18:01
 * @Created by Mccrea_Gao
 */
public class LiksoAppMain {
    public static void main(String[] args) {
        A a = new A();
        System.out.println("11 - 3 = " + a.func1(11, 3));
        System.out.println("11 - 8 = " + a.func1(11, 8));

        B b = new B();
        System.out.println("11 - 3 = " + b.func1(11, 3));
        System.out.println("11 - 3 + 9 = " + b.func2(11, 3));
    }
}


class A {
    public int func1(int num1, int num2) {
        return num1 - num2;
    }
}

class B extends A{

    // 破坏里式替换原则
    public int func1(int num1, int num2) {
        return num1 + num2;
    }


    public int func2 (int num1, int num2) {
        return func1(num1, num2) + 9;
    }
}